// pages/bookcity/bookcity.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    imgUrls: [
      'https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1544191278&di=fcd8162dcfae6a5d51b58d3898171430&imgtype=jpg&er=1&src=http%3A%2F%2Fimg.pconline.com.cn%2Fimages%2Fupload%2Fupc%2Ftx%2Fwallpaper%2F1206%2F25%2Fc1%2F12117095_1340608785366.jpg',
      'https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1543596525967&di=9fa30cfaad9176d151b1526b19922d62&imgtype=0&src=http%3A%2F%2Fb-ssl.duitang.com%2Fuploads%2Fblog%2F201510%2F22%2F20151022170822_4UAtC.jpeg',
      'https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1543596485698&di=c96dc0e6c7bec1c1ca727c678fd6b40c&imgtype=0&src=http%3A%2F%2Fimg-download.pchome.net%2Fdownload%2F1k1%2F5y%2F4b%2Foh6u45-tp2.jpg'
    ],
    height: 0,
    widHeight: 0,
    currentTab:0,
    zhangsan: [{
      imgurl: "../images/shu.png",
      mei: "每个词都知道某种魔圈",
      pin: "卡森",
      dou: "豆瓣评分8.4",
      jin: "200积分",
      off: "关闭订单",
    }, {
        imgurl: "../images/shu.png",
        mei: "每个词都知道某种魔圈",
        pin: "卡森",
        dou: "豆瓣评分8.4",
        jin: "200积分",
        off: "关闭订单",
      }, {
        imgurl: "../images/shu.png",
        mei: "每个词都知道某种魔圈",
        pin: "卡森",
        dou: "豆瓣评分8.4",
        jin: "200积分",
        off: "关闭订单",
      }, {
        imgurl: "../images/shu.png",
        mei: "每个词都知道某种魔圈",
        pin: "卡森",
        dou: "豆瓣评分8.4",
        jin: "200积分",
        off: "关闭订单",
      }, {
        imgurl: "../images/shu.png",
        mei: "每个词都知道某种魔圈",
        pin: "卡森",
        dou: "豆瓣评分8.4",
        jin: "200积分",
        off: "关闭订单",
      }, {
        imgurl: "../images/shu.png",
        mei: "每个词都知道某种魔圈",
        pin: "卡森",
        dou: "豆瓣评分8.4",
        jin: "200积分",
        off: "关闭订单",
      }, {
        imgurl: "../images/shu.png",
        mei: "每个词都知道某种魔圈",
        pin: "卡森",
        dou: "豆瓣评分8.4",
        jin: "200积分",
        off: "关闭订单",
      },  ],
    wangwu: [{
      imgurl: "../images/shu.png",
      mei: "每个词都知道某种魔圈",
      pin: "卡森",
      dou: "豆瓣评分8.4",
      jin: "200积分",
      off: "关闭订单",
    }],

     lisi: [{
      imgurl: "../images/shu.png",
      mei: "每个词都知道某种魔圈",
      pin: "卡森",
      dou: "豆瓣评分8.4",
      jin: "200积分",
      off: "关闭订单",
    }, ],
    zhaoliu: [{
      imgurl: "../images/shu.png",
      mei: "每个词都知道某种魔圈",
      pin: "卡森",
      dou: "豆瓣评分8.4",
      jin: "200积分",
      off: "关闭订单",
    },]
  },
  //滑动切换
  swiperTab: function (e) {
    var that = this;
    // 获取单个轮播循环的高度
    var heights = this.data.height;
    // 获取一级成员的数组个数
    var zhang = this.data.zhangsan.length
    // 获取二级成员的数组个数
    var lisi = this.data.lisi.length
    var wangwu = this.data.wangwu.length
    var zhaoliu=this.data.zhaoliu.length
    console.log(heights)
    that.setData({
      currentTab: e.detail.current
    });
    if (this.data.currentTab == 0) {
      that.setData({
        widHeight: heights * zhang + "px"
      });
      console.log(2222)
      console.log(this.data.zhangsan.length)
    } else if (this.data.currentTab == 1) {
      that.setData({
        widHeight: heights * wangwu + "px"
      });
      console.log(2222)
      console.log(this.data.lisi.length)
    } else if (this.data.currentTab == 2) {
      that.setData({
        widHeight: heights * lisi + "px"
      });
      console.log(2222)
      console.log(this.data.lisi.length)
    } else if (this.data.currentTab == 3) {
      that.setData({
        widHeight: heights * zhaoliu + "px"
      });
      console.log(2222)
      console.log(this.data.lisi.length)
    }
    // console.log(e.detail.current);
  },
  //点击切换
  clickTab: function (e) {

    var that = this;

    if (this.data.currentTab === e.target.dataset.current) {
      return false;
    } else {
      that.setData({
        currentTab: e.target.dataset.current
      })
    }
  }, 

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var query = wx.createSelectorQuery();
    var that = this;
    /**
     * 获取系统信息
     */
    var zhang = this.data.zhangsan.length;
    query.select('.mains').boundingClientRect(function (rect) {

      that.setData({
        // 获取要循环标签的高度
        height: rect.height,
        widHeight: rect.height * zhang + "px"
      })
    }).exec();
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})